source config.sh 

if [ "$1" = "" ];then
	echo "Please input user"
	exit
fi
if [ "$2" = "" ];then
	echo "Please input server ID"
	exit
fi
user=$1
ServerID=$2


#this IFS is very important
IFS='
'
array_a=( $(ec2-describe-instances) )


for instance in $(cat $InstanceUserFile | grep "$user" | awk {'print $1'}); do 
	for x in "${array_a[@]}"
	do
	   ifRunning=$(echo "$x" | grep "$instance" | awk {'print $6'})
	   IP=$(echo "$x" | grep "$instance" | awk {'print $14'})
	   if [ "$ifRunning" != "" ];then
	   		break 
	   fi
	done

	second="notrunning"
	if [ "$ifRunning" = "running" ];then
		second="running"
	fi	
	if [ "$instance" = "$ServerID" ];then
		echo "$instance $second server $IP "
	else
		TempServer=$(cat $InstanceServerFile | grep "$instance" | awk {'print $2'})
		if [ "$ServerID" = "$TempServer" ];then
			echo "$instance $second client $IP "
		fi
	fi
done